package com.yonyou.mm.idexport.bo;

import java.io.IOException;

import com.yonyou.mm.idexport.consts.Config;
import com.yonyou.mm.idexport.exception.ExportException;
import com.yonyou.mm.idexport.model.ItemModel;
import com.yonyou.mm.idexport.util.ConfigHelper;
import com.yonyou.mm.idexport.util.LoggerUtil;

public class CommonBO {
    LoggerUtil logger = LoggerUtil.newInstance(CommonBO.class);
    public ItemModel[] readInitDataItems(String modelName){
        ItemModel[] items = null;
        try {
            items = new ConfigHelper().readInitDataItems(modelName);
        } catch (ExportException e) {
            e.printStackTrace();
        }
        return items;
    }
    public void saveExportPath(String exportPath){
        try {
            ConfigHelper.saveExportPath(exportPath);
        } catch (ExportException e) {
            logger.err(e.getMessage());
        }
    }
    public String getExportPath(){
        String exportPath = "";
        try {
            exportPath = ConfigHelper.getExportPath();
        } catch (ExportException e) {
            logger.err(e.getMessage());
        }
        return exportPath;
    }
    
    public void openLogDirectory(){
        try {
            Runtime.getRuntime().exec("explorer.exe /select," + logger.getLogName(Config.ERROR));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
